<template>
  <div class="error-container">
    <div class="error-content">
      <div class="error-code">404</div>
      <div class="error-message">页面不存在</div>
      <div class="error-desc">抱歉，您访问的页面不存在或已被删除</div>
      <el-button type="primary" @click="goLogin">返回登录</el-button>
      <el-button @click="goRoot">返回根路径</el-button>
    </div>
  </div>
</template>

<script setup lang="ts">
import  router  from '@/router'

// 直接使用replace方法导航到登录页
const goLogin = () => {
  console.log('尝试导航到登录页')
  router.replace('/login')
}

// 添加根路径导航作为备选
const goRoot = () => {
  console.log('尝试导航到根路径')
  router.replace('/')
}

onMounted(() => {
  console.log('当前路径:', router.currentRoute.value.path)
})
</script>

<style scoped lang="scss">
.error-container {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100vh;
  background-color: #f5f7fa;

  .error-content {
    text-align: center;

    .error-code {
      font-size: 120px;
      font-weight: bold;
      color: #409eff;
      line-height: 1;
      margin-bottom: 20px;
    }

    .error-message {
      font-size: 32px;
      font-weight: 500;
      color: #303133;
      margin-bottom: 12px;
    }

    .error-desc {
      font-size: 16px;
      color: #909399;
      margin-bottom: 30px;
    }

    button {
      margin: 0 10px;
    }
  }
}
</style>

